<?php use_helper('PA_Links') ?>
<?php if(isset($columns)): ?>
<form action="<?php echo link_to_app('Store', 'searchItem', array('category' => $sf_request->getParameter('category'))) ?>" method="post">
  <table>
    <tr>
      <td>
        <select name="column">
          <?php foreach($columns as $key => $col): ?>
          <option value="<?php echo $key ?>" <?php echo isset($column) ? ($column == $key ? "selected='selected'" : "") : "" ?>><?php echo $col ?></option>
          <?php endforeach; ?>
        </select>
      </td>
      <td>
        <input type="text" size="30" name="pattern" value="<?php if(isset($pattern)) echo $pattern ?>" />
      </td>
      <td>
        <input type="submit" value="Szukaj" />
      </td>
    </tr>
  </table>
</form>
<?php endif; ?>
<?php if(isset($items) ? (count($items) ? true : false) : false): ?>
  <table id="inline_table">
    <tr>
      <th> Lp. </th>
      <th nowrap="nowrap">
        Nazwa
      </th>
      <?php if(isset($columnsObjects)): ?>
      <?php foreach($columnsObjects as $column): ?>
      <th nowrap="nowrap">
        <?php $s = explode("_", ucfirst($column->getName())); echo $s[0] ?> [ <?php echo $column->getUnit() ?> ]</a>
      </th>
      <?php endforeach; ?>
      <?php endif; ?>
      <th nowrap="nowrap">
        Ilość [ <?php echo $quantityUnit ?> ]
      </th>
      <th nowrap="nowrap">
        Kategoria
      </th>
    </tr>
    <?php foreach($items as $key => $item): ?>
    <tr>
      <td><p id="counter"></p></td>
      <td style="text-align:left" nowrap="nowrap">
        <a onclick="App.loadWindow('<?php echo link_to_app('Store', 'showItem', array('id' => $item->getId()), false)?>', 600, 500)" class="active"><?php echo $item->getName() ?></a>
      </td>
      <?php if(isset($columns) && isset($itemsExtraFields)): ?>
      <?php foreach($columnsObjects as $column): ?>
      <td><?php echo $itemsExtraFields[$item->getId()][$column->getName()]  ?></td>
      <?php endforeach; ?>
      <?php endif; ?>
      <td>
        <?php echo $item->getQuantity() ? : "<span style=\"color:red\">0</span>"; ?>
      </td>
      <td>
        <?php echo $item->getCategory() ?>
      </td>
    </tr>
    <?php endforeach; ?>
  </table>
<?php else: ?>
  <?php if(isset($items) && !count($items)): ?>
  Brak wynikow wyszukiwania dla podanych kryteriow.
  <?php endif; ?>
<?php endif; ?>